#ifndef __ORACLE_PROTOCOL_H__
#define __ORACLE_PROTOCOL_H__

#include "base_protocol.h"


#define HEADER_LEN 8

// Oracle 协议相关内容
enum PACKET_TYPE
{
    TYPE_None = 0,
    TYPE_CONNECTION = 1,
    TYPE_ACCEPT = 2,
    TYPE_ACK = 3,
    TYPE_REFUSE = 4,
    TYPE_REDIRECT = 5,
    TYPE_DATA = 6,
    TYPE_NULL = 7,
    TYPE_ABORT = 9,
    TYPE_NIOCTRL = 10,
    TYPE_RESEND = 11,
    TYPE_MARK = 12,
    TYPE_ATTENTION,
    TYPE_CONTROL,
    TYPE_DATADESC = 15,


    TYPE_MAXID = 19
};

// oracle commandID类型
enum CmdData:uint8_t
{
    cdSetProto = 0x01,
    cdSetDTY = 0x02,
    cdUserOCI = 0x03,
    cdRetSTA = 0x04,
    cdRowXH = 0x06,
    cdRowXD = 0x07,
    cdRetOPI = 0x08,
    cdFuncCmplt = 0x09,
    cdDescInfo = 0x10,
    cdPiggyBack = 0x11
};

// oracle callID类型
enum CmdUserOCI:uint8_t
{
    cOpenCursor = 0x02,
    cParseARow = 0x03,
    cExeRow = 0x04,
    cFetchRow = 0x05,
    cCloseCursor = 0x08,
    cLogOff = 0x09,
    cAutCmitOn = 0x0C,
    cAutCmitOff = 0x0D,
    cCommit = 0x0E,
    cRollback = 0x0F,
    cCloseQuery = 0x14,
    cParseEXE = 0x27,
    cDscrArr = 0x2B,
    cOrcVerNew = 0x3B,
    cBundleEXE = 0x3E,
    cFastOPIAL7 = 0x47,
    cOSQL7 = 0x4a,
    cExefetch = 0x4E,
    cO3Log2nd = 0x51,
    cO3Log1st = 0x52,
    cBundleEXEV7 = 0x5E,
    cv8Dscrarr = 0x62,
    cCursorCloseAll = 0x69,
    cGAuthCall = 0x73,
    cGetSessKey = 0x76,
    cCancelAll = 0x78,
    cPing = 0x93
};


namespace secsmart_protocol
{
    class OracleProtocol : public BaseProtocol
    {
        public:
            OracleProtocol()
            {
                databaseName = DBNAME_ORACLE;
            }

            virtual DETECT_RESULT parse(secsmart_session::session_sptr session, const uint8_t *buf, size_t size, bool is_forward);
            std::string extendInfo();

        private:
            void parseVersion(const uint8_t *buf,size_t size);

        
        private:
            std::string versionInfo = "";


    };

}

#endif